class Node:
    def __init__(self,data,next = None):
        self.data = data
        self.next = next
s = set()
def order(root):  #遍历+判断链表有环
    if hash(root) in s:
        print('有环')
        quit()
    s.add(hash(root))
    print(root.data)

    if root.next:
        root = root.next
        order(root)



e = Node(1)
d = Node(9,e)
c = Node(4,d)
b = Node(2,c)
a = Node(1,b)
e.next = b
order(a)
